<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>按钮1</button>
    <button>按钮2</button>
    <button>按钮3</button>
    <button>按钮4</button>
    <button>按钮5</button>
    
    <script src="vue/vue.js"></script>
    <script>
        
        var btns=document.getElementsByTagName('button');
        for (var i = 0 ; i < btns.length ; i++){
            /* 闭包、立即执行函数、有作用域 */
            (function(i){
                btns[i].addEventListener('click',function () { 
                    console.log('第' + i + '个按钮被点击') 
                })
            })(i)
        }
        for (var i = 0 ; i < btns.length ; i++){
            /* var定义下 if for 没有作用域 */
            btns[i].addEventListener('click',function () { 
                console.log('第' + i + '个按钮被点击') 
            })          
        }        
        for (let i = 0 ; i < btns.length ; i++){
            /* let定义下 if for 有作用域 */
            btns[i].addEventListener('click',function () { 
                console.log('第' + i + '个按钮被点击') 
                console.log('**************')
            })          
        }
        
    </script>
</body>
</html>